import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/widgets/common/tag_widget.dart';
import 'package:finance_app/src/widgets/select/mixin/check_box_mixin.dart';
import 'package:finance_app/src/widgets/select/mixin/radio_mixin.dart';
import 'package:flutter/material.dart';

class ProductCheckBox = ProductRadio with CheckBoxMixin;

class ProductRadio extends StatelessWidget with RadioMixin {
  final bool isSelect;
  final String title;
  final double minWidth;
  final String sellBuy;
  final num amount;
  final String unit;
  final bool isActivated;
  final bool isSelectMode;
  final bool enableInventory;

  const ProductRadio(
      {Key key,
      this.isSelect,
      this.unit,
      this.enableInventory,
      this.isSelectMode,
      this.isActivated,
      this.title,
      this.minWidth,
      this.sellBuy,
      this.amount})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisSize: MainAxisSize.max,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        if (isSelectMode == true) ...[
          buildSelectWidget,
          SizedBox(
            width: getDp(24),
          ),
        ],
        Expanded(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisSize: MainAxisSize.min,
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Expanded(
                    child: Text(
                      title,
                      maxLines: 1,
                      overflow: TextOverflow.ellipsis,
                      style: TextStyle(
                        color: aceBlackColor,
                        fontSize: getSp(16),
                        fontWeight: isSelect || isSelectMode != true
                            ? FontWeight.w700
                            : FontWeight.w400,
                        height: 1,
                      ),
                    ),
                  ),
                  Container(
                    alignment: Alignment.centerRight,
                    width: 92,
                    child: isActivated
                        ? Text(
                            enableInventory == true
                                ? '$amount $unit'
                                : S.current.nontracked,
                            style: TextStyle(
                              color: aceBlackColor,
                              fontSize: getSp(16),
                              fontWeight: FontWeight.w700,
                              height: 14 / 16,
                            ),
                          )
                        : RedTagWidget(
                            content: S.current.deactivated,
                          ),
                  ),
                ],
              ),
              SizedBox(
                height: getDp(6),
              ),
              Text(
                S.current.sell_buy_sellbuy(sellBuy),
                style: TextStyle(
                  color: aceBlackColor,
                  fontSize: getSp(14),
                  fontWeight: FontWeight.w400,
                  height: 1,
                ),
              )
            ],
          ),
        ),
      ],
    );
  }
}
